<template>
    <div class="photInfo-container">
        <h3>{{ photoinfo.title }}</h3>
        <p>
            <span>发表时间: {{ photoinfo.add_time | dataFormat }}</span>
            <span>点击: {{ photoinfo.click }}次</span>
        </p>
        <hr>
        <!-- 图片列表区域 -->
        <div class="photoInfo-images-list">
            <vue-preview :slides="slide1" @close="handleClose"></vue-preview>
        </div>
        <!-- 图片介绍区域 -->
        <p class="photoInfo-text" v-html="photoinfo.content"></p>
        <!-- 发表评论组件区域 -->
        <cmt-box :id="id"></cmt-box>
    </div>
</template>
<script>
//导入评论子组件
import comment from "../subcomponents/comment.vue"
import { Toast } from "mint-ui"
export default {
    data(){
        return {
            id: this.$route.params.id,//从路由中获取到的图片 id
            photoinfo: {},//图片详情
            slide1: []
        }
    },
    created(){
        this.getPhotoInfo()
        this.getPhotoInfoImgList()
    },
    methods: {
        getPhotoInfo(){
            //获取图片的详情
            this.$http.get("../../api/getphotoinfo.json").then(result => {
                if(result.body.status === 0){
                     this.photoinfo=result.body.message[0]
                   
                }else{
                    Toast("获取图片详细内容失败!")
                }
            })
        },
        getPhotoInfoImgList(){
            this.$http.get('../../api/getphotoinfolist.json').then(result => {
                if(result.body.status === 0){
                    result.body.message.forEach(item => {
                        item.alt="高清图片"
                        item.title="图片详情"
                        item.w=600;
                        item.h=400;
                    })
                    this.slide1=result.body.message
                }else{
                    Toast("图片加载失败")
                }
            })
        },
        handleClose () {
        console.log('close event')
      }
    },
    components: {
        "cmt-box": comment         
    }
}
</script>
<style lang="less" scoped>
.photInfo-container{
    padding: 0 5px;
    h3{
        width: 100%;
        height: 30px;
        font-size: 16px;
        line-height: 30px;
        text-align: center;
        color: #1fbfbf;
    }
    p{
        width: 100%;
        font-size: 13px;
        display: flex;
        justify-content: space-between;
        margin: 0;
    }
    .photoInfo-text{
        font-size: 14px;
        color: black;
    }

    
}
</style>

